Now Available!

Native .Net
Components

TList WinForms
for
.Net Framework

&

MetaDraw WinForms
for
.Net Framework



Bennet-Tec
Components
Make you
look sharp!



Home

Company

Products

Order Forms

How To

Downloads

Updates

Support

Registration

Dependencies

Links

Compatibility

Site Map


Basic How To


How To Find a Word or Phrase with ALLText

View On-Line Sample
Return to main How To Page

Search, Search & HighLight, or Search & Replace

ALLText has two built in search methods: FindPhrase and FindPhraseEX. FindPhrase searches for the next occurance of a given phrase in the document, without regard for the formatting. FindPhraseEX can be used to to search for text with specific formatting. In either case, the search begins at the current cursor position.

Input parameters of this method include specification of the control to search, the text to search for, the search direction, case sensitivity, and (for FindPhraseEX) the formatting parameters for the text being sought. For a complete list of the parameters and sample code, refer to the technical descriptions section. Upon returning, the method sets the StartPos& and StopPos& functions to the location of the found phrase. The return value is True if the phrase is found, false otherwise.

To Search and Replace, use the FindPhrase or FindPhraseEX methods, select the text which is found and set SelText or SelFText to overwrite the selection.

A sample search and replace project is included in the samples directory FIND.

Note: You may also use the FindHTag, FindNTag and FindPTag methods in ALLText HT/Pro to search for tagged phrases.

FindPhrase Method

Description: The FindPhrase method searches for a specified text string within the control`s content. The search begins at the current caret position and proceeds forward or backward according to the Direction% parameter.

If found, the method returns a positive long value or 0, designating the character count offset of the search string from the beginning of the ALLText content; else returns ATX_UNDEFINED.

Syntax:

Pos& = ALLText.FindPhrase(FindWhat$, Direction%, CaseSensitive%)

Input Parameters:

What$ - String containing the phrase to find.
Direction% - Integer (Boolean) value. If True, then search forward else search backward.
CaseSensitive% - Integer (Boolean) value. If True, then case sensitive search else case ignored.

Example:

Private Sub btnFindNext_Click()

Dim Direction As Integer, CaseSensitive As Integer, Result As Integer

Direction = 1 * optDir(0).Value 'Return a boolean value of true or false
CaseSensitive = -1 * chkMatchCase.Value 'Return a boolean value of true or false

Result = frmMain.ATX451.FindPhrase(txtFindWhat.Text, Direction, CaseSensitive)
If Result > 0 Then
btnFindNext.Caption = "Find &Next"
frmMain.ATX451.SetFocus
frmMain.ATX451.Select = 0
frmMain.ATX451.SelStart = Result
frmMain.ATX451.SelLength = Len(txtFindWhat.Text)
Else
MsgBox ("Search String Not Found, End of Search"), vbInformation, "ALLText Demo"
btnFindNext.Caption = "Find"
End If

End Sub

FindPhraseEX Method

Description: This is an enhanced search method supporting a search for text of specified format.

Syntax:

Res& = ALLText.FindPhraseEX (FindWhat As String, Direction%, CaseSensitive%,
SearchFontName$, SearchFontSize%, SearchFontWidth%, SearchFontBld%,
SearchFontItalic%, SearchFontUnder%, SearchFontStrike%,
SearchFontShadow%, SearchFontSubSup%, SearchFontColor&,
SearchFontHidden%, SearchHTag&, FoundPos&, FoundLen&)

Return Values:

TRUE = 1 - if search is successiful
UNDEF = - 4096 = &HFFFFF000&)- phrase not found

Input Parameters:

FindWhat - Text to be found. If this string is empty (=

Copyright© 2003 Bennet-Tec Information Systems, Inc. All rights reserved.